package com.dt.dubai.core.comm;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * 查询提交参数
 */

public class Querys<T> {

    public PageListData<T> queryPageListData(Mapper mapper, PageParameterData queryCondition, List<PageCondition> joinCondition, Example example, Example.Criteria criteria) {
        Page<T> page = PageHelper.startPage(queryCondition.getPNum(), queryCondition.getPSize());

        Tools.buildJoinConditiion(joinCondition, criteria);

        PageListData<T> pageListData = new PageListData<T>(queryCondition.getPNum(), queryCondition.getPSize());
        // long start = System.currentTimeMillis();
        pageListData.setList(mapper.selectByExample(example));
        // System.out.println("selectByExample->>>" + (System.currentTimeMillis() - start));
        pageListData.setTotal(page.getTotal());
        return pageListData;
    }


}
